﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace ColdStorage.DOL
{
    [Serializable]
    public class Roof
    {

        #region Roof attributes
        int iroofType = -1;

        public int iRoofType
        {
            get { return iroofType; }
            set { iroofType = value; }
        }
        double dbroofTransferCoefficient = 0.2;

        public double dbRoofTransferCoefficient
        {
            get { return dbroofTransferCoefficient; }
            set { dbroofTransferCoefficient = value; }
        }
        double dbroofLength;

        public double dbRoofLength
        {
            get { return dbroofLength; }
            set { dbroofLength = value; }
        }
        double dbroofWidth;

        public double dbRoofWidth
        {
            get { return dbroofWidth; }
            set { dbroofWidth = value; }
        }
        double dbroofTemperatureExcess;

        public double dbRoofTemperatureExcess
        {
            get { return dbroofTemperatureExcess; }
            set { dbroofTemperatureExcess = value; }
        }

        string sroofName;

        public string sRoofName
        {
            get { return sroofName; }
            set { sroofName = value; }
        }
        #endregion
       
       // Tính tổng dòng nhiệt sinh ra do Roof
        public double CalculateRoofHeat(double outsidetemp, double insideTemp)
        {
            return dbroofTransferCoefficient * dbroofLength * dbroofWidth * ((outsidetemp - insideTemp) + dbroofTemperatureExcess);
        }
        /// <summary>
        /// method to copy Roof object to a new object
        /// </summary>
        /// <returns>a new object is Roof object type</returns>
        public object Clone()
        {
            object clone;
            try
            {
                using (MemoryStream stream = new MemoryStream())
                {

                    BinaryFormatter formatter = new BinaryFormatter();

                    // Serialize this object

                    formatter.Serialize(stream, this);

                    stream.Position = 0;

                    // Deserialize to another object

                    clone = formatter.Deserialize(stream);

                }
                return clone;
            }
            catch (Exception e)
            {
                return e;
            }

        }
    }
}
